home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Think Class Libraries / WASTE TCL 2.0b2 / WASTE VA / Source / x_CAbout.cp < prev    next >
Encoding:
Text File  |  1996-06-16  |  9.2 KB  |  369 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  x_CAbout.cp
  3.  
  4.                 CAbout Dialog Director Class
  5.     
  6.     Copyright Â© 1996 Dan Crevier. All rights reserved.
  7.  
  8.     Generated by Visual Architectâ„¢
  9.  
  10.     This file is rewritten each time you generate code. You should not
  11.     make changes to this file; changes should go in the CAbout.cp
  12.     file, instead.
  13.  
  14.     If you want to change how Visual Architect generates this file, you can
  15.     change the template for this file. It is "_Dialog_cp" in the Visual Architect
  16.     Templates folder.
  17.  
  18.  ******************************************************************************/
  19.  
  20. #include "x_CAbout.h"
  21.  
  22. #include "AboutItems.h"
  23.  
  24. #include "ViewUtilities.h"
  25.  
  26. #include <CIntegerText.h>
  27. #include <Commands.h>
  28. #include <CControl.h>
  29. #include <CPopupMenu.h>
  30. #include <CPopupPane.h>
  31. #include <CArrayPane.h>
  32. #include <CIconButton.h>
  33. #include <CPictureButton.h>
  34. #include <CSwissArmyButton.h>
  35.  
  36. #include "CStaticText.h"
  37. #include "CButton.h"
  38.  
  39.  
  40. #include <CApplication.h>
  41. #include <CBartender.h>
  42. #include <Commands.h>
  43. #include <Constants.h>
  44. #include <CDecorator.h>
  45. #include <CDesktop.h>
  46. #include <CDirectorOwner.h>
  47. #include <CFile.h>
  48. #include <CList.h>
  49. #include <CPanorama.h>
  50. #include <TBUtilities.h>
  51. #include <CWindow.h>
  52.  
  53. extern    CApplication *gApplication;        /* The application                    */
  54. extern CDecorator    *gDecorator;        /* Decorator for arranging windows    */
  55. extern CDesktop        *gDesktop;            /* The visible Desktop                */
  56. extern CBartender    *gBartender;        /* Manages all menus                */
  57.  
  58.     // Define symbols for commands handled by this class
  59.     // Prevents a recompile every time any command changed.
  60.  
  61.  
  62. TCL_DEFINE_CLASS_M1(x_CAbout, CDialogDirector);
  63.  
  64. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  65.  
  66.  
  67. /******************************************************************************
  68.  Ix_CAbout
  69.  
  70.     Initialize the dialog
  71.  ******************************************************************************/
  72.  
  73. void x_CAbout::Ix_CAbout(CDirectorOwner *aSupervisor, Boolean push)
  74.  
  75. {
  76.     IDialogDirector(aSupervisor);
  77.  
  78.         // There are several circumstances where we don't want
  79.         // ProviderChanged to be called. During initialization,
  80.         // during calls to UpdateData, etc. The ignore flag
  81.         // heads these off.
  82.  
  83.     ignore = TRUE;                        /* Don't call UpdateData now        */
  84.  
  85.     MakeNewWindow();                    /* Create the dialog's window        */
  86.  
  87.     DoBeginData(push);                    /* Gather initial values            */
  88.  
  89.     ignore = FALSE;
  90. }
  91.  
  92.  
  93. /******************************************************************************
  94.  MakeNewWindow
  95.  
  96.     Create a window by reading a view resource
  97.  ******************************************************************************/
  98.  
  99. void x_CAbout::MakeNewWindow(void)
  100.  
  101. {
  102.     itsWindow = TCLGetNamedWindow("\pAbout", this);
  103.  
  104.         // Initialize pointers to the subpanes in the window
  105.  
  106.   fAbout_Stat1 = (CStaticText*) FindPane(kAbout_Stat1ID);
  107.   ASSERT(member(fAbout_Stat1, CStaticText));
  108.  
  109.   fAbout_Butn2 = (CButton*) FindPane(kAbout_Butn2ID);
  110.   ASSERT(member(fAbout_Butn2, CButton));
  111.  
  112.   fAbout_Stat3 = (CStaticText*) FindPane(kAbout_Stat3ID);
  113.   ASSERT(member(fAbout_Stat3, CStaticText));
  114.  
  115.   fAbout_Stat5 = (CStaticText*) FindPane(kAbout_Stat5ID);
  116.   ASSERT(member(fAbout_Stat5, CStaticText));
  117.  
  118. }
  119.  
  120.  
  121. /******************************************************************************
  122.  FindPane
  123.  
  124.     Locate a subpane of this window by ID. Note that Visual Architect-
  125.     generated IDs are unique within a project, so this function
  126.     will find panes within subviews, even if dynamically loaded.
  127.  ******************************************************************************/
  128.  
  129. CPane *x_CAbout::FindPane(long ID)
  130.  
  131. {
  132.     return (CPane*) itsWindow->FindViewByID(ID);
  133. }
  134.  
  135.  
  136. /******************************************************************************
  137.  DoBeginData
  138.  
  139.      Collect initial values from subclass and initialize panes
  140. ******************************************************************************/
  141.  
  142. void x_CAbout::DoBeginData(Boolean push)
  143.  
  144. {
  145.     CAboutData        data = {0};        /* The initial value record            */
  146.  
  147.     BeginData(&data);                    // Ask subclass for initial values
  148.  
  149.     if (!push)
  150.     {
  151.         DispensePaneValues(data);        // Set panes
  152.     }
  153.  
  154.         // Save the initial values in case user cancels
  155.  
  156.     saveData = data;
  157. }
  158.  
  159.  
  160. /******************************************************************************
  161.  DoEndData
  162.  
  163.      Collect final values from panes and tell subclass.
  164.      During EndData(), data argument has current values and
  165.      saveData has initial values. After EndData(), saveData
  166.      holds current values.
  167. ******************************************************************************/
  168.  
  169. void x_CAbout::DoEndData(long theCommand)
  170.  
  171. {
  172.     CAboutData        data;            /* The initial value record            */
  173.     RgnHandle            rgn;            /* Selection region                    */
  174.  
  175.                                         /* If user canceled the dialog,        */
  176.     if (theCommand == cmdCancel)        /*     return the initial values        */
  177.     {
  178.         data = saveData;
  179.     }
  180.     else
  181.         CollectPaneValues(data);        // Get current pane values
  182.  
  183.     EndData(&data);                        // Tell the derived class
  184.  
  185.     saveData = data;                    // Now has current values
  186. }
  187.  
  188.  
  189. /******************************************************************************
  190.  SetData
  191.  
  192.      Set initial values of panes. Must be called after I-function. (2.0.5)
  193. ******************************************************************************/
  194.  
  195. void x_CAbout::SetData(const CAboutData& initial)
  196. {
  197.     DispensePaneValues(initial);
  198.     saveData = initial;
  199. }
  200.  
  201.  
  202. /******************************************************************************
  203.  GetData
  204.  
  205.      Collect final values from panes. Must be called after DoEndData
  206.      (which means it is usually only meaningful for modal dialogs,
  207.      as modeless dialogs usually call DoEndData during Close()). (2.0.5)
  208. ******************************************************************************/
  209.  
  210. void x_CAbout::GetData(CAboutData& final)
  211. {
  212.     final = saveData;
  213. }
  214.  
  215.  
  216. /******************************************************************************
  217.  DispensePaneValues
  218.  
  219.      Set pane values from argument struct
  220. ******************************************************************************/
  221.  
  222. void x_CAbout::DispensePaneValues(const CAboutData& data)
  223.  
  224. {
  225.         // Initialize the panes based on the values supplied.
  226.         // The ASSERT statements ensure that the generated
  227.         // code is in synch with the view resource.
  228.  
  229. }
  230.  
  231. /******************************************************************************
  232.  CollectPaneValues
  233.  
  234.      Collect final values from panes and tell subclass
  235. ******************************************************************************/
  236.  
  237. void x_CAbout::CollectPaneValues(CAboutData& data)
  238.  
  239. {
  240.     RgnHandle            rgn;            /* Selection region                    */
  241.  
  242.                                         /* Collect values from panes        */
  243. }
  244.  
  245.  
  246. /******************************************************************************
  247.  BeginData
  248.  
  249.      Collect initial values from subclass and initialize panes.
  250.      The default function does nothing.
  251. ******************************************************************************/
  252.  
  253. void x_CAbout::BeginData(CAboutData *initial)
  254.  
  255. {
  256. }
  257.  
  258.  
  259. /******************************************************************************
  260.  UpdateData
  261.  
  262.      Tell subclass when panes change
  263. ******************************************************************************/
  264.  
  265. void x_CAbout::UpdateData(CAboutUpdate *update, long itemNo)
  266.  
  267. {
  268. }
  269.  
  270.  
  271. /******************************************************************************
  272.  EndData
  273.  
  274.      Tell subclass the final values. For a canceled modal dialog,
  275.      these are the same as the initial values.
  276. ******************************************************************************/
  277.  
  278. void x_CAbout::EndData(CAboutData *final)
  279.  
  280. {
  281. }
  282.  
  283.  
  284. /******************************************************************************
  285.  DoModalDialog    {OVERRIDE}
  286.  
  287.      Override to call EndData
  288. ******************************************************************************/
  289.  
  290. long x_CAbout::DoModalDialog(long defaultCmd)
  291.  
  292. {
  293.     long    result = CDialogDirector::DoModalDialog(defaultCmd);
  294.     
  295.     DoEndData(result);
  296.     return result;
  297. }
  298.  
  299.  
  300. /******************************************************************************
  301.  Close {OVERRIDE}
  302.  
  303.      Override to call EndData
  304. ******************************************************************************/
  305.  
  306. Boolean x_CAbout::Close(Boolean quitting)
  307.  
  308. {    
  309.     if (itsWindow && !itsWindow->active)
  310.         itsWindow->Select();
  311.  
  312.     if (EndDialog(cmdOK, TRUE))
  313.     {                                        
  314.                                         /* For a modal dialog, exit through    */
  315.         if (itsWindow->IsModal())        /*     DoModalDialog                    */
  316.         {
  317.             dismissCmd = cmdClose;
  318.             return TRUE;
  319.         }
  320.         else
  321.         {
  322.                                         /* Collect final values and call    */
  323.             DoEndData(cmdOK);            /*     EndData                        */
  324.                                         /* Do the Close, skipping            */
  325.                                         /*     CDialogDirector (7.0.4)        */
  326.             return CDirector::Close(quitting);
  327.         }
  328.     }
  329.     else
  330.         return FALSE;
  331. }
  332.  
  333.  
  334. /******************************************************************************
  335.  ProviderChanged    {OVERRIDE}
  336.      
  337.      User did something. Note that the TCL
  338.      does not currently report changes to plain CEditText items. 
  339. ******************************************************************************/
  340.  
  341. void x_CAbout::ProviderChanged(CCollaborator *aProvider, long reason, void* info)
  342.  
  343. {
  344.     CAboutUpdate    data;            /* The update value record            */
  345.     Str255    str;
  346.     Boolean    saveIgnore = ignore;
  347.     
  348.     if (ignore)                            /* Don't be a chatterbox            */
  349.         return;
  350.     ignore = TRUE;
  351.     
  352.     try_
  353.     {
  354.          if (FALSE) {}
  355.         else
  356.             CDialogDirector::ProviderChanged(aProvider, reason, info);
  357.     }
  358.     catch_all_()
  359.     {
  360.         ignore = saveIgnore;
  361.         throw_same_();
  362.     }
  363.     end_try_
  364.     
  365.     ignore = saveIgnore;                /* ProviderChanged() can't Close()!    */
  366. }
  367.  
  368.  
  369.